package com.dks.controller;

import com.dks.dto.DoctorWebDto;
import com.dks.models.TalksRecord;
import com.dks.repository.ITalksRecordRepository;
import com.dks.result.ResultModel;
import com.dks.util.PageInfo;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.time.LocalDateTime;

/**
 * 学生班级相关
 */
@RestController
@RequestMapping("talks_record")
public class TalksRecordController {

    @Resource
    private ITalksRecordRepository talksRecordRepository;


    /**
     * 提交记录
     *
     * @param talksRecord 记录
     * @author zn
     */
    @PostMapping("insert")
    public ResultModel<Boolean> insert(@RequestBody TalksRecord talksRecord) {
        return talksRecordRepository.insert(talksRecord);
    }

    /**
     * 修改记录
     *
     * @param talksRecord id 课程系列id
     * @author zn
     */
    @PostMapping("update")
    public ResultModel<Boolean> update(@RequestBody TalksRecord talksRecord) {
        return talksRecordRepository.update(talksRecord);
    }

    /**
     * 列表开始按钮
     *
     * @param talksRecord id 课程系列id
     * @author zn
     */
    @PostMapping("begin_record")
    public ResultModel<Boolean> beginRecord(@RequestBody TalksRecord talksRecord) {
        return talksRecordRepository.begin(talksRecord);
    }

    /**
     * 列表开始等待按钮
     *
     * @param talksRecord id 课程系列id
     * @author zn
     */
    @PostMapping("begin_wait_record")
    public ResultModel<Boolean> beginWaitRecord(@RequestBody TalksRecord talksRecord) {
        return talksRecordRepository.beginWaitRecord(talksRecord);
    }

    /**
     * 客户列表取消排队按钮
     *
     * @param talksRecord id 课程系列id
     * @author zn
     */
    @PostMapping("cancel_wait_record")
    public ResultModel<Boolean> cancelWaitRecord(@RequestBody TalksRecord talksRecord) {
        return talksRecordRepository.cancelWaitRecord(talksRecord);
    }

    /**
     * 客户列表结束按钮
     *
     * @param talksRecord id 课程系列id
     * @author zn
     */
    @PostMapping("end_record")
    public ResultModel<Boolean> endRecord(@RequestBody TalksRecord talksRecord) {
        return talksRecordRepository.endRecord(talksRecord);
    }

    /**
     * 医生列表结束按钮
     *
     * @param talksRecord id 课程系列id
     * @author zn
     */
    @PostMapping("doctor_end_record")
    public ResultModel<Boolean> doctorEndRecord(@RequestBody TalksRecord talksRecord) {
        return talksRecordRepository.doctorEndRecord(talksRecord);
    }

    /**
     * 查找排队列表
     *
     * @author zn
     */
    @GetMapping("selectList")
    public ResultModel<PageInfo<TalksRecord>> selectList(@Param("pageNum") Integer pageNum, @Param("pageSize") Integer pageSize, @Param("beginTime") String beginTime, @Param("departmentId") Integer departmentId) {
        return talksRecordRepository.selectList(pageNum, pageSize, beginTime,departmentId);
    }

    /**
     * 查找排队列表
     *
     * @author zn
     */
    @PostMapping("selectDoctorList")
    public ResultModel<PageInfo<TalksRecord>> selectDoctorList(@RequestBody DoctorWebDto doctorWebDto) {
        return talksRecordRepository.selectDoctorList(doctorWebDto);
    }

    /**
     * id查找
     *
     * @author zn
     */
    @GetMapping("selectById")
    public ResultModel<TalksRecord> selectById(@Param("id") Integer id) {
        return talksRecordRepository.selectById(id);
    }


    /**
     * 删除记录
     *
     * @param talksRecord 记录
     * @author zn
     */
    @PostMapping("delete")
    public ResultModel<Boolean> delete(@RequestBody TalksRecord talksRecord) {
        return talksRecordRepository.delete(talksRecord);
    }

    /**
     * 获取openid
     *
     * @param jsCode 记录
     * @author zn
     */
    @GetMapping("getWXOpenid")
    public ResultModel<Boolean> getWXOpenid(@Param("jsCode") String jsCode ) {
        return talksRecordRepository.getWXOpenid(jsCode);
    }



}
